<template>
	<view class="page">
		<view class="my-card" style="">
			<view class="text-white">
				<text v-if="!hasTask" class="zwrw">暂无任务</text>
				<view v-else>
					<view class="title_body">
						<text class="title">{{task.title}}</text>
						<button @click="see_detail(task.ucId)" class="cu-btn round my-btn">处理</button>
					</view>
					<view class="content">
						<text>所属企业：{{task.enterpriseName}}</text>
						<text>执行时间：{{task.addTime}}</text>
					</view>
				</view>
			</view>
		</view>

		<view class="utools">
			<text class="utools-title">任务管理</text>
			<view class="uk">
				<view style="" class="bg-1" @click="wbgd">
					<text>维保工单</text>
				</view>
				<view style="" class="bg-2" @click="wbrw">
					<text>维保任务</text>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		created() {
			console.info("chome create")
		
			this.getTask()
		
			let that = this
			uni.$on('refreshPage', function() {
				that.getTask()
			})
		},
		data() {
			return {
				hasTask: true,
				task: ''
			}
		},
		methods: {
			getTask() {
				let that = this
				let params = {
					"pageNum": 1,
					"pageSize": 1,
					"status": 1
				}
				// 请求数据
				let app = getApp()
				app.globalData.request({
					url: 'wx/maintenance/getInMaintenanceInfoPage',
					data: {
						...params
					}
				}).then(function(res) {
					if (res.data.data.list.length > 0) {
						that.hasTask = true
						that.task = res.data.data.list[0]
					} else {
						that.hasTask = false
					}

				}).catch(function(e) {
					that.hasTask = false
				})
			},
			wbgd() {
				uni.navigateTo({
					url: '/wb/wbgdlb/wbgdlb'
				})
			},
			wbrw() {
				uni.navigateTo({
					url: '/wb/wbrw/wbrw'
				})
			},
			see_detail(ucId) {
				uni.navigateTo({
					url: '/wb/wbxq/wbxq?ucId=' + ucId
				})
			}
		}
	}
</script>

<style scoped>
	.page {
		margin: 0 24rpx;
		margin-top: 39rpx;
		height: 400px;
	}

	.my-card {
		height: 320rpx;
		border-radius: 25upx;
		padding: 24upx 50upx;
		background: url('https://tvax2.sinaimg.cn/large/005Tv2WXgy1h0l69fybvtj309r04gq3h.jpg') no-repeat;
		background-size: cover;
	}

	.title_body {
		font-family: PingFangSC-Medium;
		font-size: 36rpx;
		color: #FFFFFF;
		text-align: left;
		margin: 40upx 0;

	}

	.my-btn {
		float: right;
		font-size: 24rpx;
		color: #458DF5;
		height: 50rpx;
	}

	.content {
		font-family: PingFangSC-Medium;
		font-size: 24rpx;
		color: #FFFFFF;
		letter-spacing: 0.39px;
		text-align: left;
		line-height: 24rpx;
		display: flex;
		flex-direction: column;
	}

	.content text {
		margin: 6px 0;
	}

	.utools {
		margin-top: 40upx;
	}

	.utools-title {
		font-size: 32rpx;
		color: #777777;
		font-weight: 600;
	}

	.uk {
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		align-items: center;
		margin-top: 20upx;
	}

	.uk view {
		width: 45%;
		height: 190upx;
		border-radius: 8px;
	}

	.uk text {

		display: flex;
		justify-content: flex-start;
		align-items: center;
		height: 100%;
		margin-left: 40rpx;
		font-size: 28rpx;
		color: #333333;
		font-weight: 600;
		width: ;
	}

	.bg-1 {
		background: url(@/static/home/cHome/icon_weibaogongdan.png) no-repeat -10rpx;
		background-size: cover;
	}

	.bg-2 {
		background: url(@/static/home/cHome/icon_weibaorenwu.png) no-repeat -10rpx;
		background-size: cover;
	}

	.zwrw {
		font-size: 48rpx;
	}
</style>
